package com.itbaizhan.produce;


import org.apache.rocketmq.client.producer.SendResult;
import org.apache.rocketmq.spring.core.RocketMQTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;

@Service
public class MessageProduce {

    @Autowired
    private RocketMQTemplate rocketMQTemplate; // 注入生产者

    @Value("${demo.rocketmq.topic}")
    private String topic;


    /**
     * 发送消息至rocketmq
     * @param message
     * @return
     */
    public SendResult sendMessage(String message){
       return  rocketMQTemplate.syncSend(topic,message);

    }



}
